﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;

namespace ShortcutMenu
{
    public partial class MainWindow : Window
    {
        double m_ScrollStepRatio = 0.0;     //滚动条的归一化步进长度
        double m_ScrollPositionRatio = 0.0; //滚动条的归一化位置
        /// <summary>
        /// 应用图标视图滚动
        /// </summary>
        private void ApplyView_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            e.Handled = true;
            m_ScrollStepRatio = ApplyView_Scroll.ViewportHeight / (ApplyView_Scroll.ExtentHeight - ApplyView_Scroll.ViewportHeight);
            m_ScrollPositionRatio = ApplyView_Scroll.ContentVerticalOffset / ApplyView_Scroll.ScrollableHeight;

            if (e.Delta > 0)
                ApplyView_Scroll.SmoothScroll(m_ScrollStepRatio, m_ScrollPositionRatio, ScrollDirection.Up);
            else if (e.Delta < 0)
                ApplyView_Scroll.SmoothScroll(m_ScrollStepRatio, m_ScrollPositionRatio, ScrollDirection.Down);
        }
    }
}
